<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2>
   <fmt:message key = "form.listDepartments"/>
   <c:out value = "${organizationName}"/>
</h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<form action = "operatorui" method = "post" name = "departmentsListForm">
   <table class = "regular">
      <thead>
         <tr>            
            <th><fmt:message key = "department.name"/></th>
            
         </tr>
      </thead>

      <tbody>
      	<c:choose>
        <c:when test="${fn:length(departmentsList) != 0}">      
         <c:forEach var = "department" items = "${departmentsList}">
            <tr>
               <td>${department.name}</td>                              
            </tr>
         </c:forEach>
         </c:when>
      <c:otherwise>
        <tr><td><center><fmt:message key="emptyList"/></center></td></tr>
      </c:otherwise>     
      </c:choose>
      </tbody>

      <tfoot>
         <tr>
            <th colspan = "1">
               <fmt:message key = "department.total"/>:
               <fmt:formatNumber value = '${fn:length(departmentsList)}'/>
            </th>
         </tr>
      </tfoot>
   </table>

<table class = "form">      
   <tr>
      <td class = "label"><fmt:message key = "department.name"/></td>
      <td><input name = "name" type = "text" value = ""></td>
   </tr>
</table>
  
   <input name = "_action" type = "hidden">   
   <input name = "organization_id" type = "hidden" value='<c:out value = "${organizationId}"/>'>   
</form>  
  
<div class="links">      
  <ul class = "navbar2">
   <li>
      <a class = "control" href = 'javascript:doAction("processDepartmentForm");'>
         <fmt:message key = "Command.add"/>
      </a>
   </li>           
  </ul> 
</div>